import axios from "axios";

// instance 实例
const instance = axios.create({
  baseURL: "/api",
  headers: {
    "Content-Type": "application/x-www-form-urlencoded",
    // "token": localStorage.getItem("token")
  }
})

// axios 请求拦截器 每次请求前，对所携带的参数做处理，headers
instance.interceptors.request.use((config) => {
  let token = localStorage.getItem("token");
  // 在请求头中设置 token
  config.headers = {
    token,
  }
  return config;
})

// 暴露对象 instance
export default instance;